<?php
$this->breadcrumbs = array(
    'Ads' => array('/ad'),
    'Create new'
);
?>
<div class="box">
    <header>
        <h5>Create ad</h5>
    </header>
    <div class="body">
        <div>
            <label>Select ads type</label>
            <select id="change_ad">
                <option value="google">Google ads</option>
                <option value="flash" <?php if (isset($_GET['type']) && $_GET['type'] == 'flash') echo 'selected' ?>>Flash ads</option>
                <option value="image" <?php if (isset($_GET['type']) && $_GET['type'] == 'image') echo 'selected' ?>>Image ads</option>
            </select>
        </div>

        <br class="clear" />

        <div id="adv-form">
            <?php
            if (get_class($model) == 'GoogleAds')
                $this->renderPartial('_google', array(
                    'model' => $model
                ));
            else if(get_class($model) == 'FlashAds')
                $this->renderPartial('_flash', array(
                    'model' => $model
                ));
            else
                $this->renderPartial('_image', array(
                    'model' => $model
                ));
            ?>

        </div>
    </div>
</div>
<script>
    $("#change_ad").change(function(){

        $.ajax({
            url : "<?php echo url('ad/ad/change') ?>",
            data : "type="+$(this).val(),
            success : function(response){
                $("#adv-form").html(response);

            }
        });
    });
</script>